var MongoClient = require('mongodb').MongoClient
var url = "mongodb://localhost:27017/"

MongoClient.connect(url, {useNewUrlParser: true, useUnifiedTopology: true}, function(err, db){
  if(err) throw err
  var dbo = db.db("laochen")
  var myobj = {username: "老陈", type: "帅", like:["唱", "跳", "开车", "代码"]}
  dbo.collection("users").insertOne(myobj, function(err, res) {
    if(err) throw err
    console.log("文档插入成功")
    db.close()
  })
})








